<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title>25. 邮箱验证中原子组的使用</title>
    </head>
    <body>
        <input type="text" name="mail" value="234432@hdcms.com.cn" />
        <span>

        </span>
    </body>
    <script>
        /*
         * 
         **/

        let mail = document.querySelector(`[name="mail"]`).addEventListener('keyup', function() {
            let reg = /^[\w-]+@([\w-]+\.)+(com|org|cc|cn|net)$/i; //234432@hdcms.com.cn
            console.log(reg.test(this.value)) //true,false
            document.querySelector('span').innerHTML = reg.test(this.value) ? '正确' : '错误'
        });
        // let reg=/^[\w-]+@[\w-]+\.(com|org|cc|cn|net)$/i;234432@qq.com
        // let reg=/^[\w-]+@([\w-]+\.)+(com|org|cc|cn|net)$/i;  //234432@hdcms.com.cn
        //     console.log(mail.match(reg))
    </script>
</html>
